/*wx.config({
    debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
    appId: 'wx8c1f87e52d0a146e', // 必填，公众号的唯一标识
    timestamp: , // 必填，生成签名的时间戳
    nonceStr: '', // 必填，生成签名的随机串
    signature: '',// 必填，签名
    jsApiList: [] // 必填，需要使用的JS接口列表
});*/

 
var readyFunc = function onBridgeReady() {
    document.querySelector('#closeWindow').addEventListener('click', function(e){
    	WeixinJSBridge.invoke('closeWindow',{
        },function(res){
            
            console.log(res);
 
       });
    });    
    
}


if (typeof WeixinJSBridge === "undefined") {
  document.addEventListener('WeixinJSBridgeReady', readyFunc, false);
} else {
  readyFunc();
}
var vm = new Vue({
		el:'#rrapp',
		data:{
			showList: true,
			title:'请进行参会认证',
			adduser:{
				 
			}
		},
		methods: {
			saveOrUpdate: function () {
				vm.adduser.openid=$('#oid').val();
	            if(!$(".form-horizontal").validationEngine("validate")) {
	                $(".formError").show();
	                return;
	            }
	           if(vm.validator()){
	                return ;
	            }

				var url = "addmtg/addInfoCert";
				$.ajax({
					type: "POST",
				    url: baseURL + url,
	                contentType: "application/json",
				    data: JSON.stringify(vm.adduser),
				    success: function(r){
				    	if(r.code === 0||r.code === 1){
				    		parent.location.href='https://mp.weixin.qq.com/s/mSPakDWIF9e4cjHIkfmUSQ'+'?v='+ new Date().getTime()+Math.random();	
				    		/*alert('验证通过，隆重有请嘉宾入场！99999623456', function(){
				    			
				    			parent.location.href='https://mp.weixin.qq.com/s/mSPakDWIF9e4cjHIkfmUSQ'+'?v='+ new Date().getTime()+Math.random();*/	
				    			/*location.href ='https://mp.weixin.qq.com/s/mSPakDWIF9e4cjHIkfmUSQ';*/
				    		  /*  location.reload();*/
				    		  /*  ifr.src = 'https://mp.weixin.qq.com/s/mSPakDWIF9e4cjHIkfmUSQ'+'?v='+ new Date().getTime()+Math.random();	
				    		    ifr.style.display = 'none';
				    		    document.body.appendChild(ifr);
				    		    setTimeout(function(){
				    		        document.body.removeChild(ifr);
				    		    }, 3000);*/
				    			 /*var u = navigator.userAgent; 
				    	            var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端 
				    	            var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端 
				    	            if(isAndroid == true){
				    	                // alert('Android!');
				    	                window.location = 'https://mp.weixin.qq.com/s/mSPakDWIF9e4cjHIkfmUSQ'+'?v='+ new Date().getTime()+Math.random();	
				    	            } else {
				    	                if(isiOS == true){
				    	                    // alert('ios！');
				    	                    window.location = 'https://mp.weixin.qq.com/s/mSPakDWIF9e4cjHIkfmUSQ'+'?v='+ new Date().getTime()+Math.random();	
				    	                }else{
				    	                    alert('请在手机端打开');
				    	                }
				    	            }*/
				    			/*if(is_weixin()){
				    				location.href='https://mp.weixin.qq.com/s/mSPakDWIF9e4cjHIkfmUSQ'+'?v='+ new Date().getTime()+Math.random();	
				    				window.open('https://mp.weixin.qq.com/s/mSPakDWIF9e4cjHIkfmUSQ'+'?v='+ new Date().getTime()+Math.random()) ;	
				    				
				    			}else{
				    				location.href='https://mp.weixin.qq.com/s/mSPakDWIF9e4cjHIkfmUSQ'+'?v='+ new Date().getTime()+Math.random();	
				    				window.open('https://mp.weixin.qq.com/s/mSPakDWIF9e4cjHIkfmUSQ'+'?v='+ new Date().getTime()+Math.random()) ;	
				    			}*/
				    			 
//								WeixinJSBridge.call('closeWindow');
//				    			window.onbeforeunload = function () {
//				    		        return "退出?";
//				    		        //return null;
//				    		    };
//				    			wx.closeWindow();
								 //WeixinJSBridge.invoke("closeWindow",{},function(e){});
							/*});*/
						}else if(r.code===2){
							localStorage.setItem("name", vm.adduser.name);
							localStorage.setItem("mobile", vm.adduser.mobile);
							//跳转完善信息页面
							/*parent.location.href = '/login.html';*/
							
							parent.location.href=baseURL+'addmtg/addFullInfoPage?oid='+$('#oid').val();
							/*  window.location.href= 'addFullInfo.html';
							  //window.location.href= '../../modules/kit/kitApiInfoDocument.html';
							    localStorage.setItem("oid", vm.adduser.openid);*/
							
						}else{
							alert(r.msg);
						}
					}
				});
			},
		     validator: function () {
		            if(isBlank(vm.adduser.name)){
		                alert("姓名不能为空");
		                return true;
		            }else if(vm.adduser.name.search("先生")!=-1||vm.adduser.name.search("小姐")!=-1||vm.adduser.name.search("女士")!=-1){
		            	
		            	 alert("姓名不能为先生或小姐/女士");
			                return true;
		            }
		            if(isBlank(vm.adduser.mobile)){
		                alert("手机号不能为空");
		                return true;
		            }
		        }
		}
	});